<?php


$DB_NAME = 'tesis';
$DB_HOST = 'localhost';
$DB_USER = 'gach';
$DB_PASS = 'gach18942bakuryu';

$mysqli = new mysqli($DB_HOST, $DB_USER, $DB_PASS, $DB_NAME);

if (mysqli_connect_errno()) {
    printf("Connect failed: %s\n", mysqli_connect_error());
    exit();
}

for ($i = 0; $i < count($_POST)-2; $i++) {
    $insertar=  explode("/", $_POST['materia_'.strval($i)]);
    
    $query="UPDATE tesis.materia SET statusmateria=1 WHERE idmateria='$insertar[0]' AND idseccion='$insertar[1]'";
    $query2="UPDATE tesis.materia SET fechastatus=sysdate() WHERE idmateria='$insertar[0]' AND idseccion='$insertar[1]'";
    $res = $mysqli->query($query) or die($mysqli->error . __LINE__);
    $res2 = $mysqli->query($query2) or die($mysqli->error . __LINE__);
}
header("Location: http://gach-laptop.no-ip.org/final/activacion.php");
?>
